#ifndef GUI_H
#define GUI_H

#include "ui_gui.h"
#include "status.h"
#include <QtNetwork>
#include <joystick.h>
#include <string>
#include <fstream>

using std::string;

class Gui : public QMainWindow
{

   Q_OBJECT

  public:
    Gui(QMainWindow *parent = 0);
    ~Gui();
     
  protected:
    void timerEvent(QTimerEvent*);
     
  private slots:
    void readPendingDatagrams();
    void calibrateDepth();
    
  private:
    bool FileExists(string);
    void setImuControl(bool);
    void sendAck(QHostAddress, quint16);
    void sendJoy(double ,double, double, double, int, int, int, int);
    void getJoyStickCommands();
    
    void renderRobot();
    void renderCompass();
    
    int timerId;
    Joystick* joy;
    
    bool imuControl;
    bool debounced;
   
    quint16 blockSize;
    
    double robRotation;

    std::ofstream datafile;
    
    Ui::Gui ui;
    QUdpSocket *udpSocket;
    Status* robots[6];
    
    QPixmap* logoPmap;
    QGraphicsScene* logoGraphicsScene;
    
    QPixmap* compassPmap;
    QGraphicsScene* compassGraphicsScene;
    QPen pen;
    QLineF compassNeedle;
    
    QPixmap* robotPmap;
    QGraphicsScene* robotGraphicsScene;
    
    bool hasJoyStick;
};
#endif
